#ifndef OPENLINEEDIT_H
#define OPENLINEEDIT_H

#include <QWidget>

#include <QLineEdit>
#include <QPushButton>
#include <QIcon>
#include <QResizeEvent>
#include <QSize>
#include <QFileInfo>

class OpenLineEdit : public QWidget
{
    Q_OBJECT
public:
	enum ButtonPosition{
		Inside,
		Outside
	};

	enum ButtonAlign{
		Right,
		Left
	};

	enum ButtonMode{
		OpenFile,
		SaveFile,
		Directory
	};

	enum AccessMode{
		ReadOnly = 0x1,
		WriteOnly = 0x2,
		FullAccess = 0x3 // ReadOnly + WriteOnly
	};

private:
	class OpenLineEditPrivate;
	OpenLineEditPrivate *d;

public:
	explicit OpenLineEdit(QWidget *parent = 0, bool checkPath = true);
	~OpenLineEdit();

	QSize sizeHint() const;
	QSize minimumSizeHint() const;

	void setButtonPosition(const OpenLineEdit::ButtonPosition &pos);
	void setButtonAlign(const OpenLineEdit::ButtonAlign &align);
	void setButtonMode(const OpenLineEdit::ButtonMode &mode);
	void setAccessMode(const OpenLineEdit::AccessMode &mode);

	OpenLineEdit::ButtonPosition buttonPosition() const;
	OpenLineEdit::ButtonAlign buttonAlign() const;
	OpenLineEdit::ButtonMode buttonMode() const;
	OpenLineEdit::AccessMode accessMode() const;


	QString text() const;

	QString buttonText() const;

	QIcon buttonIcon() const;

	bool isReadOnly() const;

	bool checkPath() const;

	bool isModified() const;
	void setModified(bool);

	bool isEmpty() const;
protected:
	void resizeEvent(QResizeEvent *);


private slots:
	void getFileName();
	void textEdited( const QString &text );

public slots:
	void setText(const QString &text);
	void setButtonText(const QString &text);


	void setButtonIcon(const QString &icon);
	void setButtonIcon(const QIcon &icon);

	void setReadOnly(const bool &readOnly);

	void setCheckPath(const bool &flag);
};

#endif // OPENLINEEDIT_H
